from django.conf.urls.defaults import *
from blog.models import *

post_archive = {
  'queryset': Post.live.all(),
  'date_field': 'publish',
  'allow_empty': True,
}
post_list = {
  'queryset': Post.live.all(),
  'allow_empty': True,
  'paginate_by': 20,
}
post_detail = {
  'queryset': Post.live.all(),
  'date_field': 'publish',
}
category_list = {
  'queryset': Category.objects.all(),
}

urlpatterns = patterns('',
  url(
    regex   = '^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', 
    view    = 'django.views.generic.date_based.object_detail', 
    kwargs  = dict(post_detail, slug_field='slug'),
    name    = 'blog_detail',
  ),
  url(
    regex   = '^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
    view    = 'django.views.generic.date_based.archive_day',
    kwargs  = post_archive,
    name    = 'blog_archive_day',
  ),
  url(
    regex   = '^(?P<year>\d{4})/(?P<month>[a-z]{3})/$',
    view    = 'django.views.generic.date_based.archive_month',
    kwargs  = post_archive,
    name    = 'blog_archive_month',
  ),
  url(
    regex   = '^(?P<year>\d{4})/$',
    view    = 'django.views.generic.date_based.archive_year',
    kwargs  = post_archive,
    name    = 'blog_archive_year',
  ),
  url(
    regex   = '^categories/(?P<slug>[-\w]+)/$',
    view    = 'blog.views.category_detail',
    name    = 'blog_category_detail',
  ),
  url (
    regex   = '^categories/$',
    view    = 'django.views.generic.list_detail.object_list',
    kwargs  = category_list,
    name    = 'blog_category_list',
  ),
  url(
    regex   = '^$',
    view    = 'django.views.generic.list_detail.object_list',
    kwargs  = post_list,
    name    = 'blog_index',
  ),
)